package com.yidu.logisticssystem.service.impl;

import com.yidu.logisticssystem.entity.LogisticsGate;
import com.yidu.logisticssystem.dao.LogisticsGateDao;
import com.yidu.logisticssystem.entity.vo.GateVo;
import com.yidu.logisticssystem.service.LogisticsGateService;
import net.bytebuddy.asm.Advice;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.sql.Date;
import java.util.List;

/**
 * 出勤表(LogisticsGate)表服务实现类
 *
 * @author 宋玉玲
 * @since 2021-03-08 16:46:49
 */
@Service("logisticsGateService")
public class LogisticsGateServiceImpl implements LogisticsGateService {
    @Resource
    private LogisticsGateDao logisticsGateDao;

    /**
     * 通过ID查询单条数据
     *
     * @param staffNum,gateDates 主键
     * @return 实例对象
     */
    @Override
    public LogisticsGate queryById(String staffNum, String gateDates) {
        return this.logisticsGateDao.queryById(staffNum,gateDates);
    }

    /**
     * 查询多条数据
     *
     * @param offset 查询起始位置
     * @param limit  查询条数
     * @return 对象列表
     */
    @Override
    public List<LogisticsGate> queryAllByLimit(int offset, int limit) {
        return this.logisticsGateDao.queryAllByLimit(offset, limit);
    }

    /**
     * 新增数据
     *
     * @param logisticsGate 实例对象
     * @return 实例对象
     */
    @Override
    public LogisticsGate insert(LogisticsGate logisticsGate) {
        this.logisticsGateDao.insert(logisticsGate);
        return logisticsGate;
    }

    /**
     * 修改数据
     *
     * @param logisticsGate 实例对象
     * @return 实例对象
     */
    @Override
    public LogisticsGate update(LogisticsGate logisticsGate) {
        this.logisticsGateDao.update(logisticsGate);
        return this.queryById(logisticsGate.getStaffNum(), logisticsGate.getGateDates());
    }

    /**
     * 通过主键删除数据
     *
     * @param gateId 主键
     * @return 是否成功
     */
    @Override
    public int deleteById(Integer gateId) {
        return this.logisticsGateDao.deleteById(gateId);
    }


    /**
     * 查询所有
     * @param vo
     * @return
     */
    @Override
    public List<LogisticsGate> queryAll(GateVo vo) {
        return this.logisticsGateDao.queryAll(vo);
    }


    /**
     * 根据id查询
     * @param gateId
     * @return
     */
    @Override
    public LogisticsGate selectId(int gateId) {
        return this.logisticsGateDao.selectId(gateId);
    }


    /**
     * 根据id修改
     * @param logisticsGate
     * @return
     */
    @Override
    public int updateId(LogisticsGate logisticsGate) {
        return this.logisticsGateDao.updateId(logisticsGate);
    }

    /**
     * 批量删除
     * @param gateId
     * @return
     */
    @Override
    public int delete(String gateId) {
        String[] idArray = gateId.split(",");
        return this.logisticsGateDao.delete(idArray);
    }

    @Override
    public int query(LogisticsGate logisticsGate) {
        System.out.println("============");
        return this.logisticsGateDao.query(logisticsGate);
    }
}
